package org.lex.elec.apps.cad.model;

import org.lex.elec.model.datatype.Phase;
import org.lex.elec.util.LoadUtils;

public abstract class BaseLoad implements Load {
	private double power = 0;
	private double demandFactor = 1;
	private double powerFactor = 0.9;
	private Phase phase = Phase.triphase;
	private int voltage = 380;

	@Override
	public double getCalculatedPower() {
		return this.power * this.powerFactor;
	}

	public double getPower() {
		return power;
	}

	public void setPower(double power) {
		LoadUtils.checkPower(power);
		this.power = power;
	}

	public double getDemandFactor() {
		return demandFactor;
	}

	public void setDemandFactor(double demandFactor) {
		LoadUtils.checkDemandFactor(demandFactor);
		this.demandFactor = demandFactor;
	}

	public double getPowerFactor() {
		return powerFactor;
	}

	public void setPowerFactor(double powerFactor) {
		LoadUtils.checkPowerFactor(powerFactor);
		this.powerFactor = powerFactor;
	}

	public Phase getPhase() {
		return phase;
	}

	public void setPhase(Phase phase) {
		this.phase = phase;
	}

	public int getVoltage() {
		return voltage;
	}

	public void setVoltage(int voltage) {
		LoadUtils.checkVoltage(voltage);
		this.voltage = voltage;
	}
}
